package com.liuqi.business.controller.front;

import com.github.pagehelper.PageInfo;
import com.liuqi.business.model.MiningConfigModelDto;
import com.liuqi.business.model.MiningOrderModelDto;
import com.liuqi.business.service.MiningConfigService;
import com.liuqi.business.service.MiningOrderService;
import com.liuqi.response.ReturnResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Mr.Liu
 * @date: 2021/3/19 18:08
 * @version: 1.0
 * @class: MiningConfigController
 * @desc: 合约控制器
 */
@Api(description = "合约控制器")
@RestController
@RequestMapping(value = "/front")
public class MiningConfigController {
    @Autowired
    private MiningConfigService miningConfigService;

    @Autowired
    private MiningOrderService miningOrderService;

    @ApiOperation(value = "首页合约分页")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "pageNum", value = "当前页", required = false, paramType = "query", defaultValue = "1"),
            @ApiImplicitParam(dataType = "Integer", name = "pageSize", value = "条数", required = false, paramType = "query", defaultValue = "20")
    })
    @GetMapping(value = "/miningConfigList")
    public ReturnResponse getMiningConfigPage(@RequestParam(defaultValue = "1", required = false) final Integer pageNum,
                                              @RequestParam(defaultValue = "20", required = false) final Integer pageSize) {
        PageInfo<MiningConfigModelDto> page = miningConfigService.queryFrontPageByDto(new MiningConfigModelDto(), pageNum, pageSize);
        return ReturnResponse.backSuccess(page);

    }

    @ApiOperation(value = "我的合约分页")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "pageNum", value = "当前页", required = false, paramType = "query", defaultValue = "1"),
            @ApiImplicitParam(dataType = "Integer", name = "pageSize", value = "条数", required = false, paramType = "query", defaultValue = "20")
    })
    @GetMapping(value = "/miningOrderList")
    public ReturnResponse getMiningOrderPage(@RequestParam(defaultValue = "1", required = false) final Integer pageNum,
                                             @RequestParam(defaultValue = "20", required = false) final Integer pageSize) {

        PageInfo<MiningOrderModelDto> page = miningOrderService.queryFrontPageByDto(new MiningOrderModelDto(), pageNum, pageSize);
        return ReturnResponse.backSuccess(page);
    }

}
